package com.lyfy.sd.order.config;

import com.lyfy.sd.order.vo.RespVo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

/**
 * @author: 谢星星
 * @date: 2022/10/2 21:10
 * @description:
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler(Throwable.class)
    public RespVo globalException(HttpServletResponse response, Throwable throwable){

        return RespVo.builder()
                .msg("FAIL")
                .code("911")
                .result(throwable.getMessage())
                .build();
    }
}
